package com.popcorn.aboard.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.popcorn.aboard.dao.AboardDAO;
import com.popcorn.aboard.model.AboardModel;
import com.popcorn.action.Action;
import com.popcorn.action.ActionForward;

public class AboardAddAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		AboardDAO AboardDAO = new AboardDAO();
		AboardModel AboardModel = new AboardModel();
		ActionForward forward = new ActionForward();
		
   		boolean result=false;
   		
   		try{	
   			AboardModel.setTITLE(request.getParameter("TITLE"));
   			AboardModel.setCONTENT(request.getParameter("CONTENT"));
   			AboardModel.setREG_DTM(request.getParameter("REG_DTM"));
   			//aboardModel.setREG_ID(request.getParameter("REG_ID"));

   			result=AboardDAO.modelInsert(AboardModel);
   			System.out.println("============aboardAddAction============");
   			System.out.println("1."+request.getParameter("REG_DTM"));
	   		if(result==false){
	   			System.out.println("DB ?�록 ?�패");
	   			return null;
	   		}
	   		System.out.println("DB ?�록 ?�공");
	   		
	   		forward.setRedirect(true);
	   		forward.setPath("AboardListDB.go"); 
	   		return forward;
	   		
  		}catch(Exception ex){
   			ex.printStackTrace();
   		}
		
		return null;
	}

}
